import { pinyin } from 'pinyin-pro';

const funBdsJsResult = function funBdsJsResult(expression, value) {
  if (expression == 'fullPinYinFun') {
    return fullPinYinFun(value);
  } else if (expression == 'firstPinYinFun') {
    return firstPinYinFun(value);
  }
};

function fullPinYinFun(value) {
  let str = pinyin(value, { toneType: 'none' });
  //let str = pinyin(value, { pattern: 'first' });
  let newStr = str.replace(/\s/g, '');
  return newStr;
}

function firstPinYinFun(value) {
  let str = pinyin(value, { toneType: 'none', pattern: 'first' });
  //let str = pinyin(value, { pattern: 'first' });
  let newStr = str.replace(/\s/g, '');
  return newStr;
}

export { funBdsJsResult };
